//------------Sonic CD Results Script-------------//
//--------Scripted by Christian Whitehead 'The Taxman'--------//
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//

//-------Aliases-------//
#alias Object.Value1: SelectedOption
#alias Object.Value2: RouteIndex
#alias Object.Value6: SpriteSheet3
#alias Object.Value7: SpriteSheet2
#alias Object[32].Value4: RouteXPos
#alias Object[32].YPos: MainYPos

sub ObjectMain
	Options.SaveComplete=1
	switch Object.PropertyValue
	case 0
		switch Object.State
		case 0
			Object.Value0=288
			Object.State++
			SetScreenFade(0,0,0,255)
			break
		case 1
			if Object.Value0>0
				Object.Value0-=8
			else
				PlayMusic(Options.Soundtrack)
				Object.State++
			endif
			SetScreenFade(0,0,0,Object.Value0)
			break
		case 2
			TempValue0=SelectedOption
			TempValue0*=240
			CheckEqual(Object.YPos,TempValue0)
			TempValue1=CheckResult
			TempValue0=Screen.XSize
			TempValue0-=88
			TempValue0*=RouteIndex
			CheckEqual(Object.Value4,TempValue0)
			TempValue1&=CheckResult
			if TempValue1==1
				if KeyPress.Up==1
					if SelectedOption>0
						SelectedOption--
						PlaySfx(23,0)
					endif
				endif
				if KeyPress.Down==1
					if SelectedOption<4
						SelectedOption++
						PlaySfx(23,0)
					endif
				endif
				if KeyPress.ButtonB==1
					if SelectedOption==4
						Object.State++
						Music.Volume-=50
						PlaySfx(27,0)
					else
						SelectedOption=4
						PlaySfx(23,0)
					endif
				endif
				CheckTouchRect(14,54,65,73)
				if CheckResult>-1
					SelectedOption=0
					PlaySfx(23,0)
				endif
				CheckTouchRect(14,78,65,97)
				if CheckResult>-1
					SelectedOption=1
					PlaySfx(23,0)
				endif
				CheckTouchRect(14,126,65,145)
				if CheckResult>-1
					if SelectedOption==3
						Object.State++
						Music.Volume-=50
						PlaySfx(19,0)
					else
						SelectedOption=3
						PlaySfx(23,0)
					endif
				endif
				CheckTouchRect(14,150,65,169)
				if CheckResult>-1
					if SelectedOption==4
						Object.State++
						Music.Volume-=50
						PlaySfx(27,0)
					else
						SelectedOption=4
						PlaySfx(23,0)
					endif
				endif
				switch SelectedOption
				case 1
					if KeyPress.Left==1
						if RouteIndex>0
							RouteIndex--
							PlaySfx(23,0)
						endif
					endif
					if KeyPress.Right==1
						if RouteIndex<Object.Value3
							RouteIndex++
							PlaySfx(23,0)
						endif
					endif
					break
				case 2
                    if KeyPress.Start==1
                        Object.State++
                        Music.Volume-=50
                        PlaySfx(27,0)
                    endif
                    break
				case 3
					if KeyPress.Start==1
						Object.State++
						Music.Volume-=50
						PlaySfx(19,0)
					endif
					break
				case 4
					if KeyPress.Start==1
						Object.State++
						Music.Volume-=50
						PlaySfx(27,0)
					endif
					break
				endswitch
			endif
			TempValue0=SelectedOption
			TempValue0*=240
			if Object.YPos>TempValue0
				Object.YPos-=8
			else
				if Object.YPos<TempValue0
					Object.YPos+=8
				endif
			endif
			TempValue0=Screen.XSize
			TempValue0-=88
			TempValue0*=RouteIndex
			if Object.Value4>TempValue0
				Object.Value4-=8
				if Object.Value4<TempValue0
					Object.Value4=TempValue0
				endif
			else
				if Object.Value4<TempValue0
					Object.Value4+=8
					if Object.Value4>TempValue0
						Object.Value4=TempValue0
					endif
				endif
			endif
			break
		case 3
			if Object.Value0<288
				Object.Value0+=8
			else
				switch SelectedOption
				case 2
					Stage.ActiveList=REGULAR_STAGE
					Stage.ListPos=70
					LoadStage()
				break
				case 3
					if Options.GameMode==1
						ArrayPos1=Options.SaveSlot
					else
						ArrayPos1=Options.NoSaveSlot
					endif
					ArrayPos1<<=3
					ArrayPos1++
					SaveRAM[ArrayPos1]=3
					ArrayPos1++
					SaveRAM[ArrayPos1]=0
					ArrayPos1++
					SaveRAM[ArrayPos1]=0
					ArrayPos1++
					SaveRAM[ArrayPos1]=0
					ArrayPos1++
					SaveRAM[ArrayPos1]=0
					ArrayPos1++
					SaveRAM[ArrayPos1]=50000
					ArrayPos1++
					SaveRAM[ArrayPos1]=0
					if Options.GameMode==1
						ArrayPos1=Options.SaveSlot
					else
						ArrayPos1=Options.NoSaveSlot
					endif
					ArrayPos1*=800
					ArrayPos1+=800
					SaveRAM[ArrayPos1]=0
					ArrayPos1++
					SaveRAM[ArrayPos1]=0
					ArrayPos1++
					SaveRAM[ArrayPos1]=0
					ArrayPos1++
					SaveRAM[ArrayPos1]=0
					ArrayPos1++
					SaveRAM[ArrayPos1]=0
					if Options.GameMode==1
						WriteSaveRAM()
					endif
					Player.Lives=3
					Player.Score=0
					Player.ScoreBonus=50000
					Good_Future_List=0
					Good_Future_Count=0
					Good_Future=0
					Transporter_Destroyed=0
					MetalSonic_Destroyed=0
					MetalSonic_List=0
					SpecialStage.TimeStones=0
					SpecialStage.ListPos=0
					LampPost.Check=0
					Stage.ActiveList=REGULAR_STAGE
					Stage.ListPos=0
					LoadStage()
				break
				case 4
					Stage.ActiveList=PRESENTATION_STAGE
					Stage.ListPos=1
					LoadStage()
				break
				endswitch
			endif
			TempValue0=Object.Value0
			if TempValue0>255
				TempValue0=255
			endif
			if SelectedOption==3
				SetScreenFade(208,255,224,TempValue0)
			else
				SetScreenFade(0,0,0,TempValue0)
			endif
			break
		endswitch
		break
	case 1
		TempValue0=Object[32].Value1
		TempValue0*=24
		TempValue0+=48
		if Object.YPos<TempValue0
			Object.YPos+=2
			Object.Animation=1
		else
			if Object.YPos>TempValue0
				Object.YPos-=2
				Object.Animation=1
			else
				Object.Animation=0
			endif
		endif
		if Object.Animation!=Object.PrevAnimation
			if Object.Animation==0
				Object.AnimationTimer=0
				Object.Frame=112
			else
				Object.Frame=115
			endif
		else
			if Object.Animation==0
				Object.AnimationTimer++
				if Object.AnimationTimer>60
					TempValue0=Object.AnimationTimer
					TempValue0%=20
					if TempValue0==0
						if Object.Frame==113
							Object.Frame=114
						else
							Object.Frame=113
						endif
					endif
				endif
			else
				Object.AnimationTimer++
				if Object.AnimationTimer>1
					Object.AnimationTimer=0
					if Object.Frame==117
						Object.Frame=115
					else
						Object.Frame++
					endif
				endif
			endif
		endif
		Object.PrevAnimation=Object.Animation
		break
	endswitch
endsub


sub ObjectDraw
	switch Object.PropertyValue
	case 0
		// Left menu
		DrawSpriteScreenXY(0,0,0)
		TempValue0=SelectedOption
		TempValue0+=2
		DrawSpriteScreenXY(TempValue0,0,0)
		break
	case 1
		// Sonic
		TempValue0=Object.SpriteSheet
		if Object.Animation==0
			Object.SpriteSheet=SpriteSheet2
		else
			Object.SpriteSheet=SpriteSheet3
		endif
		DrawSpriteScreenFX(Object.Frame,FX_FLIP,Object.XPos,Object.YPos)
		Object.SpriteSheet=TempValue0
		break
	case 2
		// Backdrop
		TempValue0=Object.YPos
		TempValue0-=MainYPos
		TempValue0%=96
		while TempValue0<Screen.YSize
			TempValue1=Object.XPos
			while TempValue1<Screen.XSize
				DrawSpriteScreenXY(1,TempValue1,TempValue0)
				TempValue1+=96
			loop
			TempValue0+=96
		loop
		break
	case 3
		// Player icon
		TempValue0=Object.YPos
		TempValue0-=MainYPos
		DrawSpriteScreenXY(7,Object.XPos,TempValue0)
		TempValue1=Object.SpriteSheet
		Object.SpriteSheet=SpriteSheet2
		DrawSpriteScreenXY(8,Object.XPos,TempValue0)
		Object.SpriteSheet=TempValue1
		break
	case 4
		// Play time
		TempValue0=Object.YPos
		TempValue0-=MainYPos
		DrawSpriteScreenXY(9,Object.XPos,TempValue0)
		DrawSpriteScreenXY(67,Object.XPos,TempValue0)
		DrawSpriteScreenXY(11,Object.XPos,TempValue0)
		TempValue0+=11
		DrawNumbers(43,Object.Value1,TempValue0,Object.Value2,2,8,1)
		TempValue1=Object.Value1
		TempValue1-=16
		DrawSpriteScreenXY(54,TempValue1,TempValue0)
		TempValue1-=7
		DrawNumbers(43,TempValue1,TempValue0,Object.Value3,2,8,1)
		TempValue1-=14
		DrawSpriteScreenXY(53,TempValue1,TempValue0)
		TempValue1-=9
		if Object.Value5>0
			DrawNumbers(43,TempValue1,TempValue0,Object.Value4,2,8,1)
			TempValue1-=14
			DrawSpriteScreenXY(53,TempValue1,TempValue0)
			TempValue1-=8
			DrawNumbers(43,TempValue1,TempValue0,Object.Value5,4,8,0)
		else
			DrawNumbers(43,TempValue1,TempValue0,Object.Value4,2,8,0)
		endif
		break
	case 5
		// Generic number
		TempValue0=Object.YPos
		TempValue0-=MainYPos
		DrawSpriteScreenXY(9,Object.XPos,TempValue0)
		DrawSpriteScreenXY(10,Object.XPos,TempValue0)
		DrawSpriteScreenXY(Object.Value2,Object.XPos,TempValue0)
		TempValue0+=11
		DrawNumbers(43,Object.Value1,TempValue0,Object.Value3,5,8,0)
		break
	case 6
		// Time Stones
		TempValue0=Object.YPos
		TempValue0-=MainYPos
		DrawSpriteScreenXY(9,Object.XPos,TempValue0)
		DrawSpriteScreenXY(10,Object.XPos,TempValue0)
		DrawSpriteScreenXY(13,Object.XPos,TempValue0)
		TempValue2=0
		TempValue3=14
		while TempValue2<7
			GetBit(TempValue1,SpecialStage.TimeStones,TempValue2)
			TempValue2++
			if TempValue1==1
				DrawSpriteScreenXY(TempValue3,Object.XPos,TempValue0)
			endif
			TempValue3++
		loop
		break
	case 7
		// Level info
		TempValue0=Object.YPos
		TempValue0-=MainYPos
		TempValue1=Object.XPos
		TempValue1-=RouteXPos
		DrawSpriteScreenXY(9,TempValue1,TempValue0)
		DrawSpriteScreenXY(10,TempValue1,TempValue0)
		DrawSpriteScreenXY(24,TempValue1,TempValue0)
		DrawSpriteScreenXY(25,TempValue1,TempValue0)
		TempValue0+=2
		TempValue1+=9
		TempValue2=Object.Value2
		TempValue2/=10
		if TempValue2!=8
			TempValue2+=26
			DrawSpriteScreenXY(TempValue2,TempValue1,TempValue0)
			TempValue1+=Object.Value3
			DrawSpriteScreenXY(33,TempValue1,TempValue0)
			TempValue1+=27
			TempValue2=Object.Value2
			TempValue2%=10
			TempValue2/=4
			TempValue2+=44
			DrawSpriteScreenXY(TempValue2,TempValue1,TempValue0)
			if Screen.XSize<377
				TempValue0+=15
				TempValue1=Object.XPos
				TempValue1-=RouteXPos
				TempValue1+=23
				TempValue2=Object.Value2
				TempValue2%=10
				if TempValue2<8
					TempValue2%=4
				else
					TempValue2-=6
				endif
				TempValue2+=34
				DrawSpriteScreenXY(TempValue2,TempValue1,TempValue0)
				TempValue0-=1
				TempValue1+=81
				DrawSpriteScreenXY(Object.Value4,TempValue1,TempValue0)
				TempValue0+=7
				TempValue1=Object.Value1
				TempValue1-=RouteXPos
				DrawNumbers(55,TempValue1,TempValue0,Object.Value5,2,8,1)
				TempValue1-=15
				DrawSpriteScreenXY(66,TempValue1,TempValue0)
				TempValue1-=5
				DrawNumbers(55,TempValue1,TempValue0,Object.Value6,2,8,1)
				TempValue1-=15
				DrawSpriteScreenXY(65,TempValue1,TempValue0)
				TempValue1-=5
				DrawNumbers(55,TempValue1,TempValue0,Object.Value7,2,8,0)
			else
				switch TempValue2
				case 44
					TempValue1+=10
					break
				case 45
					TempValue1+=12
					break
				default
					TempValue1+=11
					break
				endswitch
				TempValue2=Object.Value2
				TempValue2%=10
				if TempValue2<8
					TempValue2%=4
				else
					TempValue2-=6
				endif
				TempValue2+=34
				DrawSpriteScreenXY(TempValue2,TempValue1,TempValue0)
				TempValue0+=18
				TempValue1=Object.XPos
				TempValue1-=RouteXPos
				TempValue1+=23
				DrawSpriteScreenXY(Object.Value4,TempValue1,TempValue0)
				TempValue1=Object.Value1
				TempValue1-=RouteXPos
				DrawNumbers(55,TempValue1,TempValue0,Object.Value5,2,8,1)
				TempValue1-=15
				DrawSpriteScreenXY(66,TempValue1,TempValue0)
				TempValue1-=5
				DrawNumbers(55,TempValue1,TempValue0,Object.Value6,2,8,1)
				TempValue1-=15
				DrawSpriteScreenXY(65,TempValue1,TempValue0)
				TempValue1-=5
				DrawNumbers(55,TempValue1,TempValue0,Object.Value7,2,8,0)
			endif
		else
			DrawSpriteScreenXY(41,TempValue1,TempValue0)
			TempValue1+=Object.Value3
			TempValue2=Object.Value2
			TempValue2%=10
			TempValue2+=44
			DrawSpriteScreenXY(TempValue2,TempValue1,TempValue0)
			TempValue0+=18
			TempValue1=Object.XPos
			TempValue1-=RouteXPos
			TempValue1+=23
			DrawSpriteScreenXY(Object.Value4,TempValue1,TempValue0)
			TempValue1=Object.Value1
			TempValue1-=RouteXPos
			DrawNumbers(55,TempValue1,TempValue0,Object.Value5,2,8,1)
			TempValue1-=15
			DrawSpriteScreenXY(66,TempValue1,TempValue0)
			TempValue1-=5
			DrawNumbers(55,TempValue1,TempValue0,Object.Value6,2,8,1)
			TempValue1-=15
			DrawSpriteScreenXY(65,TempValue1,TempValue0)
			TempValue1-=5
			DrawNumbers(55,TempValue1,TempValue0,Object.Value7,2,8,0)
		endif
		break
	case 8
		// Score
		TempValue0=Object.YPos
		TempValue0-=MainYPos
		DrawSpriteScreenXY(9,Object.XPos,TempValue0)
		DrawSpriteScreenXY(10,Object.XPos,TempValue0)
		DrawSpriteScreenXY(12,Object.XPos,TempValue0)
		TempValue0+=11
		DrawNumbers(43,Object.Value1,TempValue0,Player.Score,10,8,0)
		break
	case 12
		// Message
		TempValue0=Object.YPos
		TempValue0-=MainYPos
		DrawSpriteScreenXY(109,Object.XPos,TempValue0)
		DrawSpriteScreenXY(Object.Value0,Object.XPos,TempValue0)
		break
	case 13
		// Route page
		TempValue0=Object.YPos
		TempValue0-=MainYPos
		TempValue1=Object[32].Value3
		TempValue1++
		DrawNumbers(55,Object.XPos,TempValue0,TempValue1,2,8,0)
		TempValue2=Object.XPos
		TempValue2-=8
		if TempValue1>9
			TempValue2-=8
		endif
		DrawSpriteScreenXY(118,TempValue2,TempValue0)
		TempValue2-=8
		TempValue1=Object[32].Value2
		TempValue1++
		DrawNumbers(55,TempValue2,TempValue0,TempValue1,2,8,0)
		break
	endswitch
endsub


sub ObjectStartup
	TempValue1=Screen.XSize
	TempValue1-=17
	if Options.GameMode==1
		ArrayPos0=Options.SaveSlot
	else
		ArrayPos0=Options.NoSaveSlot
	endif
	ArrayPos0*=800
	ArrayPos0+=800
	ArrayPos1=32
	// Left menu
	Object[ArrayPos1].Priority=1
	Object[ArrayPos1].XPos=0
	Object[ArrayPos1].YPos=0
	Object[ArrayPos1].DrawOrder=4
	// Menu cursor
	LoadSpriteSheet("Global/Pause_EN.gif")
	ArrayPos1++
	ResetObjectEntity(ArrayPos1,TypeName[Results],1,80,48)
	Object[ArrayPos1].Priority=1
	Object[ArrayPos1].DrawOrder=4
	Object[ArrayPos1].Direction=FACING_LEFT
	Object[ArrayPos1].Frame=112
	Object[ArrayPos1].Value7=Object.SpriteSheet
	switch stage.PlayerListPos
	case 0
		LoadSpriteSheet("Players/Sonic1.gif")
		break
	case 1
		LoadSpriteSheet("Players/Tails3.gif")
		break
	case 2
		LoadSpriteSheet("Players/Amy1.gif")
		break
	endswitch
	Object[ArrayPos1].Value6=Object.SpriteSheet
	// Backdrop
	ArrayPos1++
	ResetObjectEntity(ArrayPos1,TypeName[Results],2,88,0)
	Object[ArrayPos1].Priority=1
	// Player icon
	switch stage.PlayerListPos
	case 0
		LoadSpriteSheet("Global/Display.gif")
		break
	case 1
		LoadSpriteSheet("Global/Display_t.gif")
		break
	case 2
		LoadSpriteSheet("Global/Display_a.gif")
		break
	endswitch
	ArrayPos1++
	ResetObjectEntity(ArrayPos1,TypeName[Results],3,100,7)
	Object[ArrayPos1].Priority=1
	Object[ArrayPos1].Value7=Object.SpriteSheet
	// Play time
	ArrayPos1++
	ResetObjectEntity(ArrayPos1,TypeName[Results],4,124,7)
	Object[ArrayPos1].Priority=1
	Object[ArrayPos1].Value1=TempValue1
	TempValue2=SaveRAM[ArrayPos0]
	Object[ArrayPos1].Value2=TempValue2
	Object[ArrayPos1].Value2%=100
	TempValue2/=100
	Object[ArrayPos1].Value3=TempValue2
	Object[ArrayPos1].Value3%=60
	TempValue2/=60
	Object[ArrayPos1].Value4=TempValue2
	Object[ArrayPos1].Value4%=60
	if Options.GameMode==1 //save slot 1-4
		if Stage.PlayerListPos==0
			if TempValue2<25
				SaveRAM[267]=1
				WriteSaveRAM()
				SetAchievement(10,100) //Unlock "Just In Time" achievement
			endif
		endif
		if SpecialStage.TimeStones>126
			SaveRAM[265]=1 //Unlock Time Zone Select from previous completed Steam save
			WriteSaveRAM()
		endif
	endif
	if Options.GameMode!=-2
		if SaveRAM[300]==1
			if TempValue2>=9
				if SaveRAM[301]==0
					if TempValue2<15
						SaveRAM[36]=1
						SaveRAM[301]=1
						WriteSaveRAM()
						if Stage.PlayerListPos==0
							SaveRAM[304]=1
							WriteSaveRAM()
						endif
					else
						SaveRAM[300]=0
						WriteSaveRAM()
					endif
				else
					Stage.ActiveList=PRESENTATION_STAGE
					Stage.ListPos=8
				endif
				LoadStage()
			endif
		endif
	endif
	TempValue2/=60
	Object[ArrayPos1].Value5=TempValue2
	// Score
	ArrayPos0++
	ArrayPos1++
	ResetObjectEntity(ArrayPos1,TypeName[Results],8,100,41)
	Object[ArrayPos1].Priority=1
	Object[ArrayPos1].Value1=TempValue1
	Object[ArrayPos1].Value2=12
	TempValue2=SaveRAM[ArrayPos0]
	Object[32].Value3=TempValue2
	Object[32].Value3+=4
	Object[32].Value3/=5
	Object[32].Value3--
	// Time Stones
	ArrayPos1++
	ResetObjectEntity(ArrayPos1,TypeName[Results],6,100,74)
	Object[ArrayPos1].Priority=1
	// Time travel uses //Time Warps
	ArrayPos0++
	ArrayPos1++
	ResetObjectEntity(ArrayPos1,TypeName[Results],5,100,107)
	Object[ArrayPos1].Priority=1
	Object[ArrayPos1].Value1=TempValue1
	Object[ArrayPos1].Value2=21
	Object[ArrayPos1].Value3=SaveRAM[ArrayPos0]
	// Levels cleared //Deaths
	ArrayPos0++
	ArrayPos1++
	ResetObjectEntity(ArrayPos1,TypeName[Results],5,100,206)
	Object[ArrayPos1].Priority=1
	Object[ArrayPos1].Value1=TempValue1
	Object[ArrayPos1].Value2=22
	Object[ArrayPos1].Value3=SaveRAM[ArrayPos0]
	// Transporters destroyed
	ArrayPos0++
	ArrayPos1++
	ResetObjectEntity(ArrayPos1,TypeName[Results],5,100,140)
	Object[ArrayPos1].Priority=1
	Object[ArrayPos1].Value1=TempValue1
	Object[ArrayPos1].Value2=23
	TempValue0=0
	TempValue3=0
	TempValue4=0
	while TempValue3<14
		GetBit(TempValue0,Good_Future_List,TempValue3)
		TempValue4+=TempValue0
		TempValue3++
	loop
	Object[ArrayPos1].Value3=TempValue4
	// Projectors destroyed
	ArrayPos1++
	ResetObjectEntity(ArrayPos1,TypeName[Results],5,100,173)
	Object[ArrayPos1].Priority=1
	Object[ArrayPos1].Value1=TempValue1
	Object[ArrayPos1].Value2=68
	if MetalSonic_List>11
		MetalSonic_List=12
	endif
	Object[ArrayPos1].Value3=MetalSonic_List
	// Route
	TempValue3=247
	TempValue4=100
	TempValue5=0
	while TempValue5<TempValue2
		ArrayPos1++
		ResetObjectEntity(ArrayPos1,TypeName[Results],7,TempValue4,TempValue3)
		Object[ArrayPos1].Priority=1
		Object[ArrayPos1].Value1=TempValue1
		Object[ArrayPos1].Value1+=TempValue4
		Object[ArrayPos1].Value1-=100
		ArrayPos0++
		Object[ArrayPos1].Value2=SaveRAM[ArrayPos0]
		TempValue6=SaveRAM[ArrayPos0]
		TempValue6/=10
		switch TempValue6
		case 0
			Object[ArrayPos1].Value3=105
			break
		case 1
			Object[ArrayPos1].Value3=109
			break
		case 2
			Object[ArrayPos1].Value3=96
			break
		case 3
			Object[ArrayPos1].Value3=120
			break
		case 4
			Object[ArrayPos1].Value3=122
			break
		case 5
			Object[ArrayPos1].Value3=133
			break
		case 6
			Object[ArrayPos1].Value3=121
			break
		case 8
			Object[ArrayPos1].Value3=95
			break
		endswitch
		ArrayPos0++
		Object[ArrayPos1].Value4=SaveRAM[ArrayPos0]
		Object[ArrayPos1].Value4+=38
		ArrayPos0++
		TempValue6=SaveRAM[ArrayPos0]
		Object[ArrayPos1].Value5=TempValue6
		Object[ArrayPos1].Value5%=100
		TempValue6/=100
		Object[ArrayPos1].Value6=TempValue6
		Object[ArrayPos1].Value6%=60
		TempValue6/=60
		Object[ArrayPos1].Value7=TempValue6
		TempValue3+=45
		if TempValue3>=470
			TempValue3=247
			TempValue4+=Screen.XSize
			TempValue4-=88
		endif
		TempValue5++
	loop
	// Page number
	ArrayPos1++
	TempValue0=Screen.XSize
	TempValue0-=12
	ResetObjectEntity(ArrayPos1,TypeName[Results],13,TempValue0,468)
	Object[ArrayPos1].Priority=1
	TempValue0=Screen.XSize
	TempValue0-=88
	TempValue0/=2
	TempValue0+=88
	// Select
	ArrayPos1++
	ResetObjectEntity(ArrayPos1,TypeName[Results],12,TempValue0,600)
	Object[ArrayPos1].Priority=1
	Object[ArrayPos1].Value0=119
	// Retry
	ArrayPos1++
	ResetObjectEntity(ArrayPos1,TypeName[Results],12,TempValue0,840)
	Object[ArrayPos1].Priority=1
	Object[ArrayPos1].Value0=110
	// Exit
	ArrayPos1++
	ResetObjectEntity(ArrayPos1,TypeName[Results],12,TempValue0,1080)
	Object[ArrayPos1].Priority=1
	Object[ArrayPos1].Value0=111
	LoadSpriteSheet("Global/Summary.gif")
	SpriteFrame(0,0,88,240,1,1) // 0: Left Menu
	SpriteFrame(0,0,96,96,90,1) // 1: Backdrop
	SpriteFrame(16,56,48,16,187,1) // 2: "STATS" (sel)
	SpriteFrame(16,80,48,16,187,18) // 3: "ROUTE" (sel)
	SpriteFrame(16,104,48,16,187,35) // 4: "OPTS" (sel)
	SpriteFrame(16,128,48,16,187,52) // 5: "RETRY" (sel)
	SpriteFrame(16,152,48,16,187,69) // 6: "EXIT" (sel)
	SpriteFrame(0,0,18,18,236,1) // 7: Player icon box
	SpriteFrame(1,1,16,16,187,189) // 8: Player icon
	SpriteFrame(0,0,186,26,1,261) // 9: Info box
	TempValue0=Screen.XSize
	TempValue0-=276
	SpriteFrame(TempValue0,0,169,26,18,261) // 10: Info box extension
	SpriteFrame(9,2,65,13,189,149) // 11: "PLAY TIME:"
	SpriteFrame(9,2,97,13,90,197) // 12: "LEVELS VISITED:" //Score
	SpriteFrame(9,2,82,13,90,211) // 13: "TIME STONES:"
	TempValue1=Screen.XSize
	if Screen.XSize>=360
		TempValue1-=268
		TempValue2=24
	else
		TempValue1-=220
		TempValue2=16
	endif
	SpriteFrame(TempValue1,9,16,16,189,163) // 14: Time Stone 1
	TempValue1+=TempValue2
	SpriteFrame(TempValue1,9,16,16,206,163) // 15: Time Stone 2
	TempValue1+=TempValue2
	SpriteFrame(TempValue1,9,16,16,223,163) // 16: Time Stone 3
	TempValue1+=TempValue2
	SpriteFrame(TempValue1,9,16,16,189,180) // 17: Time Stone 4
	TempValue1+=TempValue2
	SpriteFrame(TempValue1,9,16,16,206,180) // 18: Time Stone 5
	TempValue1+=TempValue2
	SpriteFrame(TempValue1,9,16,16,223,180) // 19: Time Stone 6
	TempValue1+=TempValue2
	SpriteFrame(TempValue1,9,16,16,189,197) // 20: Time Stone 7
	SpriteFrame(9,2,114,13,90,225) // 21: "TIME TRAVEL USES:" //Time Warps
	SpriteFrame(9,2,103,13,1,315) // 22: "LEVELS CLEARED:" //Deaths
	SpriteFrame(9,2,99,13,1,329) // 23: "TRANSPORTERS:"
	SpriteFrame(17,25,175,7,12,280) // 24: Info box BL extension
	SpriteFrame(TempValue0,25,169,7,18,280) // 25: Info box BR extension
	SpriteFrame(0,0,101,13,105,315) // 26: "PALMTREE PANIC"
	SpriteFrame(0,0,105,13,1,343) // 27: "COLLISION CHAOS"
	SpriteFrame(0,0,92,13,107,343) // 28: "TIDAL TEMPEST"
	SpriteFrame(0,0,116,13,1,357) // 29: "QUARTZ QUADRANT"
	SpriteFrame(0,0,118,13,118,357) // 30: "WACKY WORKBENCH"
	SpriteFrame(0,0,129,13,1,371) // 31: "STARDUST SPEEDWAY"
	SpriteFrame(0,0,117,13,131,371) // 32: "METALLIC MADNESS"
	SpriteFrame(0,0,23,13,205,225) // 33: "ZONE" //Act
	SpriteFrame(0,0,54,13,188,261) // 34: "PRESENT"
	SpriteFrame(0,0,31,13,206,197) // 35: "PAST"
	SpriteFrame(0,0,80,13,174,329) // 36: "GOOD FUTURE"
	SpriteFrame(0,0,72,13,1,385) // 37: "BAD FUTURE"
	SpriteFrame(0,0,72,8,173,214) // 38: "LEVEL CLEAR"
	SpriteFrame(0,0,36,8,1,422) // 39: "DEATH"
	SpriteFrame(0,0,50,8,1,413) // 40: "RESTART"
	SpriteFrame(0,0,91,13,1,288) // 41: "SPECIAL STAGE"
	SpriteFrame(0,0,95,8,104,302) // 42: "BAD FUTURE WARP"
	SpriteFrame(0,0,7,13,193,393) // 43: "0"
	SpriteFrame(0,0,5,13,202,393) // 44: "1"
	SpriteFrame(0,0,7,13,211,393) // 45: "2"
	SpriteFrame(0,0,7,13,220,393) // 46: "3"
	SpriteFrame(0,0,8,13,229,393) // 47: "4"
	SpriteFrame(0,0,7,13,238,393) // 48: "5"
	SpriteFrame(0,0,7,13,247,393) // 49: "6"
	SpriteFrame(0,0,7,13,193,410) // 50: "7"
	SpriteFrame(0,0,7,13,202,410) // 51: "8"
	SpriteFrame(0,0,7,13,211,410) // 52: "9"
	SpriteFrame(1,4,3,9,205,499) // 53: ":"
	SpriteFrame(3,8,3,4,223,486) // 54: "."
	SpriteFrame(1,0,6,8,190,86) // 55: "0"
	SpriteFrame(3,0,3,8,201,86) // 56: "1"
	SpriteFrame(1,0,6,8,208,86) // 57: "2"
	SpriteFrame(1,0,6,8,217,86) // 58: "3"
	SpriteFrame(1,0,6,8,226,86) // 59: "4"
	SpriteFrame(1,0,6,8,235,86) // 60: "5"
	SpriteFrame(0,0,7,8,243,86) // 61: "6"
	SpriteFrame(1,0,6,8,190,95) // 62: "7"
	SpriteFrame(0,0,7,7,198,95) // 63: "8"
	SpriteFrame(1,0,6,8,208,95) // 64: "9"
	SpriteFrame(3,0,3,8,201,140) // 65: ":"
	SpriteFrame(4,5,3,2,220,136) // 66: "."
	TempValue0-=24
	SpriteFrame(TempValue0,0,169,26,18,261) // 67: Info box extension short
	SpriteFrame(9,2,82,13,79,469) // 68: "PROJECTORS:"
	SpriteFrame(9,2,38,13,122,455) // 69: "BUILD:"
	SpriteFrame(9,2,33,13,1,288) // 70: "SEED:"
	SpriteFrame(9,2,35,13,35,288) // 71: "MODE:"
	SpriteFrame(9,2,68,13,52,427) // 72: "MAIN PATH:"
	SpriteFrame(9,2,85,13,90,98) // 73: "MAX BW JUMP:"
	SpriteFrame(9,2,84,13,90,112) // 74: "MAX FW JUMP:"
	SpriteFrame(9,2,55,13,66,455) // 75: "BW PROB:"
	SpriteFrame(9,2,77,13,1,469) // 76: "ALLOW SAME:"
	SpriteFrame(9,2,40,13,207,315) // 77: "MUSIC:"
	SpriteFrame(9,2,39,13,141,497) // 78: "ITEMS:"
	SpriteFrame(9,2,74,13,90,126) // 79: "TIME POSTS:"
	SpriteFrame(9,2,88,13,90,140) // 80: "CHECKPOINTS:"
	SpriteFrame(9,2,64,13,90,154) // 81: "PALETTES:"
	SpriteFrame(9,2,34,13,149,182) // 82: "UFOS:"
	SpriteFrame(9,2,43,13,135,168) // 83: "WATER:"
	SpriteFrame(1,1,6,12,212,479) // 84: "/"
	SpriteFrame(1,5,6,3,230,483) // 85: "-"
	TempValue0=Screen.XSize
	TempValue0-=109
	TempValue1=TempValue0
	TempValue1-=71
	SpriteFrame(TempValue1,11,71,13,71,288) // 86: "ALL STAGES"
	TempValue1=TempValue0
	TempValue1-=48
	SpriteFrame(TempValue1,11,48,13,143,288) // 87: "ROUNDS"
	TempValue1=TempValue0
	TempValue1-=31
	SpriteFrame(TempValue1,11,31,13,192,288) // 88: "ACTS"
	TempValue1=TempValue0
	TempValue1-=81
	SpriteFrame(TempValue1,11,81,13,74,385) // 89: "TIME PERIODS"
	TempValue1=TempValue0
	TempValue1-=112
	SpriteFrame(TempValue1,11,112,13,57,399) // 90: "BRANCHING PATHS"
	TempValue1=TempValue0
	TempValue1-=63
	SpriteFrame(TempValue1,11,63,13,52,413) // 91: "SEGMENTS"
	TempValue1=TempValue0
	TempValue1-=27
	SpriteFrame(TempValue1,11,27,13,220,239) // 92: "WILD"
	TempValue1=TempValue0
	TempValue1-=48
	SpriteFrame(TempValue1,11,48,13,116,413) // 93: "SHADOW"
	TempValue1=TempValue0
	TempValue1-=64
	SpriteFrame(TempValue1,11,64,13,1,455) // 94: "ACT CLEAR"
	TempValue1=TempValue0
	TempValue1-=76
	SpriteFrame(TempValue1,11,76,13,90,225) // 95: "TIME TRAVEL"
	TempValue1=TempValue0
	TempValue1-=55
	SpriteFrame(TempValue1,11,55,13,136,441) // 96: "ANY EXIT"
	TempValue1=TempValue0
	TempValue1-=22
	SpriteFrame(TempValue1,11,22,13,165,126) // 97: "YES"
	TempValue1=TempValue0
	TempValue1-=16
	SpriteFrame(TempValue1,11,16,13,236,225) // 98: "NO"
	SpriteFrame(TempValue1,11,16,13,212,225) // 99: "ON"
	TempValue1=TempValue0
	TempValue1-=21
	SpriteFrame(TempValue1,11,21,13,224,288) // 100: "OFF"
	TempValue1=TempValue0
	TempValue1-=61
	SpriteFrame(TempValue1,11,61,13,101,329) // 101: "SEPARATE"
	TempValue1=TempValue0
	TempValue1-=36
	SpriteFrame(TempValue1,11,36,13,200,343) // 102: "MIXED"
	TempValue1=TempValue0
	TempValue1-=15
	SpriteFrame(TempValue1,11,15,13,52,441) // 103: "1:1"
	TempValue1=TempValue0
	TempValue1-=83
	SpriteFrame(TempValue1,11,83,13,52,441) // 104: "1:1 PER STAGE"
	TempValue1=TempValue0
	TempValue1-=30
	SpriteFrame(TempValue1,11,30,13,161,455) // 105: "EASY"
	TempValue1=TempValue0
	TempValue1-=44
	SpriteFrame(TempValue1,11,44,13,90,168) // 106: "MEDIUM"
	TempValue1=TempValue0
	TempValue1-=31
	SpriteFrame(TempValue1,11,31,13,155,154) // 107: "HARD"
	TempValue1=TempValue0
	TempValue1-=58
	SpriteFrame(TempValue1,11,58,13,90,182) // 108: "ADD ONLY"
	SpriteFrame(-109,-9,218,18,1,242) // 109: Info bar
	SpriteFrame(-85,-7,170,13,1,483) // 110: "RESTART FROM FIRST LEVEL."
	SpriteFrame(-70,-7,139,13,1,497) // 111: "RETURN TO MAIN MENU."
	switch stage.PlayerListPos
	case 0
		SpriteFrame(0,0,16,24,1,103) // 112: Sonic Idle 1
		SpriteFrame(0,0,16,24,18,103) // 113: Sonic Idle 2
		SpriteFrame(0,0,16,24,35,103) // 114: Sonic Idle 3
		SpriteFrame(0,0,16,24,36,232) // 115: Sonic Walk 1
		SpriteFrame(0,0,16,24,53,232) // 116: Sonic Walk 2
		SpriteFrame(0,0,16,24,70,232) // 117: Sonic Walk 3
		break
	case 1
		SpriteFrame(0,0,16,24,52,103) // 112: Tails Idle 1
		SpriteFrame(0,0,16,24,69,103) // 113: Tails Idle 2
		SpriteFrame(0,0,16,24,86,103) // 114: Tails Idle 3
		SpriteFrame(0,0,16,24,172,1) // 115: Tails Walk 1
		SpriteFrame(0,0,16,24,189,1) // 116: Tails Walk 2
		SpriteFrame(0,0,16,24,206,1) // 117: Tails Walk 3
		break
	case 2
		SpriteFrame(0,0,16,24,103,103) // 112: Amy Idle 1
		SpriteFrame(0,0,16,24,120,103) // 113: Amy Idle 2
		SpriteFrame(0,0,16,24,137,103) // 114: Amy Idle 3
		SpriteFrame(0,0,16,24,36,232) // 115: Amy Walk 1
		SpriteFrame(0,0,16,24,53,232) // 116: Amy Walk 2
		SpriteFrame(0,0,16,24,70,232) // 117: Amy Walk 3
		break
	endswitch
	SpriteFrame(2,1,5,6,209,132) // 118: "/"
	TempValue1=TempValue0
	TempValue1-=125
	SpriteFrame(-92,-7,183,13,1,455) // 119: "CONTINUE FROM ZONE SELECT."
	LoadPalette("Summary.act",0,128,0,128)
	SetMusicTrack("JP/DAGarden.ogg",0,1)
endsub

sub RSDK
	LoadSpriteSheet("Global/Display.gif")
	SetEditorIcon(Icon0,SingleIcon,-16,-16,32,32,1,143)
endsub
